<template>
  <div class="edit-dictionary" >
    <el-dialog title="修改字典信息" :visible.sync="editFormVisible" width="25%" align="left" :before-close="close">
     <el-form ref="form" :model="form"  size="small" :rules="rules" label-width="100px">
         <el-form-item label="字典编码:" prop="attrCode">
             <el-input v-model="form.attrCode"  placeholder="请输字典编码"></el-input>
         </el-form-item>
         <el-form-item label="自定义名称:" prop="attrName">
             <el-input v-model="form.attrName" placeholder="请输入自定义名称"></el-input>
         </el-form-item>
         <el-form-item label="状态:" prop="disenable">
             <el-radio  label="1" v-model="form.disenable">启用</el-radio>
             <el-radio  label="0" v-model="form.disenable">禁用</el-radio>
         </el-form-item>
         <el-form-item label="创建人:" prop="creator">
             <el-input v-model="form.creator" placeholder="请输入创建人"></el-input>
         </el-form-item>
         <el-form-item label="优先排序值:" prop="attrOrderId">
             <el-input type="number" v-model="form.attrOrderId" placeholder="请输入优先排序值"></el-input>
         </el-form-item>
         <el-form-item align="right">
          <el-button type="primary" @click="submit">提交</el-button>
          <el-button @click="close">取消</el-button>
        </el-form-item>
     </el-form>
   </el-dialog>
 </div>
</template>
<script>
export default {
  props:["editFormVisible","editDictInfoForm","editDIcInfoSubmit"],
  data(){
    return{
      form:{},
      rules:{
        attrCode:[
            { required: true, message: '请输入字典编码', trigger: 'blur' }
        ],
        disenable:[
            { required: true, message: '请输入启用状态', trigger: 'blur' }
        ],
        attrName:[
            { required: true, message: '请输入自定义名称', trigger: 'blur' }
        ],
        creator:[
            { required: true,message: '请输入创建人',trigger: 'blur' }
        ],
        attrOrderId:[
            {required: true, message: '请输入排序值', trigger: 'blur'}
        ]
      }
    }
  },
  methods:{
    close(){
       this.$emit('update:editFormVisible', false)
    },
    submit(){
      this.$refs['form'].validate((valid) => {
         if (valid) {
           this.editDIcInfoSubmit(this.form);
         }else{
             this.$message.error("请按规则填写");
         }
      })
    }
  },
  created(){
     this.form = this.editDictInfoForm;
  }
}
</script>
